<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="jquery-1.9.1.js"></script>
</head>
<body>
    <form method="post" class="logon" >
        账号<input type="text" class="username" placeholder="请输入账号"><span class="s1"></span><br/>
        密码<input type="password" class="password" placeholder="请输入密码"><br/>
        邮箱<input type="text" class="emal" placeholder="请输入邮箱"><br/>
        <input type="submit" class="btn">
    </form>
        <script type="text/javascript">

            $(".username").blur(function () {
                $.ajax({
                    "url": "/myservlet",
                    "type": "POST",
                    "data": {"username": $(".username").val()},
                    "dataType": "json"
                }).done(function (data) {
                  if(data==0){
                      if($(".username").val().length>5){
                          $(".s1").html("账号已存在")
                          console.log(data);
                      }
                  }
                   if(data==1){
                      if($(".username").val().length>5){
                       $(".s1").html("账号可以使用")
                      }
                      $(".btn").click(function () {
                          $.ajax({
                              "url": "/myservlet02",
                              "type": "POST",
                              "data": {"username": $(".username").val(),
                                  "password":$(".password").val(),
                                  "emal":$(".emal").val()
                              },
                              "dataType": "json"
                          }).done(function (str) {
                              if(str=="ok"){
                                  console.log(str); 
                              }
                              if(str=="no"){
                                  console.log(str);
                              }
                             if(str=="no1"){
                                  console.log(str);
                             }
                          })

                      })

                   }
                  }).fail()
                

              }
             )


        </script>

</body>
</html>